/**
 * @fileOverview svg容器
 */
var Color = gg.module('datatype.Color');

module.exports = gg.createClass({
    attributes: {
        label: {
            type: 'datatype.String',
            label: '标签',
            defaultValue: '',
            setter: function(v) {

            }
        },
        stroke: {
            type: 'datatype.Color',
            label: '轮廓颜色',
            defaultValue: {r: 255, g: 0, b: 0},
            setter: function(v) {
                this.defaultSetter('stroke', v);
                this.node.setAttributes('stroke', Color.rgb(v));
            }
        },
        strokeWidth: {
            type: 'datatype.Number',
            label: '轮廓宽度',
            defaultValue: 1,
            setter: function(v) {
                this.defaultSetter('strokeWidth', v);
                this.node.setAttributes('strokeWidth', v);
            }
        },
        fill: {
            type: 'datatype.Color',
            label: '填充颜色',
            defaultValue: {r: 0, g: 0, b: 255},
            setter: function(v) {
                this.defaultSetter('fill', v);
                this.node.setAttributes('fill', Color.rgb(v));
            }
        }
    },
    methods: {
        /**
         * 创建svg元素
         */
        createElement: function(tag) {
            return document.createElementNS('http://www.w3.org/2000/svg', tag);
        },
        /**
         * 计算边界盒
         */
        bbox: function() {

        },
        /**
         * @override
         */
        createNode: function() {
            return this.createElement('g');
        },
        /**
         * @override
         */
        destroyNode: function() {
            this.node.remove();
        }
    },
    events: {
        event1: '事件1'
    }
}, 'ui.Base', []);